package com.ysdzz.hadoop;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

public class UserCityReducer extends Reducer<Text, LongWritable,Text,LongWritable> {

	@Override
	protected void reduce(Text key, Iterable<LongWritable> vals,
			Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
		Iterator<LongWritable> it = vals.iterator();
		LongWritable count = new LongWritable();
		while(it.hasNext()){
			count.set(count.get()+it.next().get());
		}
		context.write(key, count);
	}
	
}
